package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.impl.SysOperLogServiceImpl;
import com.atguigu.spzx.common.entity.SysOperLog;
import com.atguigu.spzx.common.result.Result;
import com.atguigu.spzx.manager.vo.sysOperLog.SysOperLogQueryReqVo;
import com.atguigu.spzx.manager.vo.sysOperLog.SysOperLogQueryRespVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * SysOperLogController
 * </p>
 *
 * @author flyduck
 * @since 2023/10/26
 */
@Api(value = "SysOperLog管理", tags = "SysOperLog管理")
@RestController
@RequestMapping(value="/admin/system/sysOperLog")
public class SysOperLogController {

    @Autowired
    private SysOperLogServiceImpl sysOperLogService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("/getOperLogPageByQuery/{page}/{limit}")
    public Result index(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Long page,

            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Long limit,

            @ApiParam(name = "sysOperLogVo", value = "查询对象", required = false)
                    SysOperLogQueryReqVo sysOperLogQueryVo) {
        Page<SysOperLog> pageParam = new Page<>(page, limit);
        IPage<SysOperLogQueryRespVo> pageModel = sysOperLogService.getOperLogPageByQuery(pageParam,sysOperLogQueryVo);
        return Result.ok(pageModel);
    }

    @ApiOperation("根据id查询")
    @GetMapping("/getOperLogById/{id}")
    public Result<SysOperLogQueryRespVo> getOperLogById(@PathVariable("id") Long id){
        SysOperLogQueryRespVo queryRespVo = sysOperLogService.getOperLogById(id);
        return Result.ok(queryRespVo);
    }
}
